package com.xmy.solution.controller;

import com.xmy.common.core.controller.BaseController;
import com.xmy.common.core.domain.AjaxResult;
import com.xmy.common.core.page.TableDataInfo;
import com.xmy.solution.domain.UserSolutionFavorites;
import com.xmy.solution.domain.dto.solution.SolutionAppResDTO;
import com.xmy.solution.domain.dto.solution.SolutionReqDTO;
import com.xmy.solution.domain.dto.solution.SolutionsPageDTO;
import com.xmy.solution.domain.dto.userFavorites.UserFavoritesDTO;
import com.xmy.solution.service.IUserSolutionFavoriteService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/solution/favorite")
public class UserSolutionFavoriteController extends BaseController {
    @Autowired
    private IUserSolutionFavoriteService userSolutionFavoriteService;
    @PostMapping("/favoriteSolution")
    public AjaxResult favorite(@RequestBody UserFavoritesDTO userSolution){
        return toAjax(userSolutionFavoriteService.setFavorite(userSolution));
    }
    @GetMapping("/favoriteSolutionList")
    public TableDataInfo list(@RequestParam("userId") Long userId) {
        startPage();
        List<SolutionAppResDTO> list = userSolutionFavoriteService.selectSolutionsVOList(userId);
        return getDataTable(list);
    }
}
